/**
 * Created with JetBrains WebStorm.
 * User: Administrator
 * Date: 13-6-8
 * Time: 下午1:12
 * To change this template use File | Settings | File Templates.
 */

Ext.define('cloud.view.productassess.ProductAssess', {
    extend: 'Ext.navigation.View',
    xtype: 'productassess',
    requires: ['Ext.List', 'Ext.TitleBar', 'Ext.field.Select', 'Ext.field.Search'],
    config: {
        items: [
            {
                xtype: 'container',
                layout: 'hbox',
                title: '产品评价列表',
                items: [
                    {
                        xtype: 'toolbar',
                        ui: 'dark',
                        docked: 'top',
                        items: [
                            {  xtype: 'textfield',
                                id: 'productassess_search',
                                name: 'productassess_search',
                                placeHolder: '请输入用户名称'
                                //  flex: 2
                            }
//                            {xtype: 'spacer'} ,
//                            {
//                                xtype: 'selectfield',
//                                id: 'productassess_select',
//                                name: 'productassess_select',
//
//                                //  flex: 1,
//                                options: [
//                                    {
//                                        text: '根据用户ID查询',
//                                        value: 'cuid'
//                                    },
//                                    {
//                                        text: '根据产品ID查询',
//                                        value: 'cpid'
//                                    }
//                                ]
//                            }
                        ]
                    },
                    {
                        xtype: 'list',
                        id: 'productassessSelect',
                        flex: 1,
                        store: 'ProductAssessAreaFindStore',
                        emptyText: '还没有产品评价',
                        pressedCls: false,
                        selectedCls: false,
                        cls: 'x-list2',
                        onItemDisclosure: true,
                        itemTpl: ['' +
                            '<div class="listName">{messages}</div>',
                            '<div class="listConten"> ' +
                                '<span>产品名称：{[values.product.name]}</span>  ' +
                                '<span>用户名：{cuname}</span>  ' +
                                '<span>平分数：{grade}</span>  ' +
                                '<span>支持数：{supportnum}</span></div>'

                        ].join(''),
                        listeners: {
                            painted: function () {
                                var message = Ext.getStore('ProductAssessAreaFindStore');
                                message.load(
                                    {params: {cadid: localStorage.getItem('cadid')}}
                                );
                               message .getProxy().setExtraParam('cadid', localStorage.getItem('cadid'));
                            }
                        },
                        plugins: [
                            {
                                xclass: 'Ext.plugin.PullRefresh',
                                pullRefreshText: '下拉可以更新',
                                releaseRefreshText: '松开开始更新',
                                style: 'top:12px',
                                loadingText: '正在刷新……',
                                refreshFn: function (loaded, arguments) {
                                   // loaded.getList().getStore().getProxy().setExtraParam('cadid', localStorage.getItem('cadid')); //设置proxy参数
                                    loaded.getList().getStore().loadPage(1, {
                                        callback: function (record, operation, success) {
                                            Ext.Viewport.unmask();
                                        }, scope: this });
                                }
                            },
                            {
                                xclass: 'Ext.plugin.ListPaging',
                                loadMoreText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">点击加载更多。。。。</h2>',
                                noMoreRecordsText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">没有更多条记录了</h2>',
                                autoPaging: false //设置为TRUE将自动触发
                            }
                        ]
                    }
                ]
            }
        ]
    }
});